<?php
/**
 * (crontab) sp-创建请求报告
 */
namespace App\Crontab\Daily\SpApi;

use App\Jobs\AmazonApi\SpApi\GrabCreateReport as GGrabCreateReport;
use App\Models\Basics\AmazonAccount;
class GrabCreateReport
{
    /**
     * 亚马逊报告-通用
     * @param $data
     * @param array $where
     * @param bool $multi
     * @return void
     */
    public static function grab($data, array $where = [], bool $multi = false){

        $where['api'] = 1;
        $accounts = AmazonAccount::optionsForApi($where);
        $re = [];
        foreach ($accounts as $account){
            $marketplace_ids = $account->account_country->pluck('marketplace_id')->toArray();
            GGrabCreateReport::dispatch($account,$data,$marketplace_ids,$multi)->onQueue('sp-report');
            $re[$account->id] = true;
        }
        var_dump($re);
    }
}
